<?php
/**
 * 邀请记录
 */

namespace app\admin\controller;



use app\admin\model\InviteRecord;
use app\admin\model\UserModel;
use think\Request;

class Invite extends  Common
{

    public function getIndex(Request $request)
    {
       

//        $invite_user_id=[23,54];
//        $user_id=65;
//        $master_id=56;
        $keyword=$request->param('keyword');
       
        $search_type = $request->param('search_type');

        $option =['user_id'=>null,'invite_user_id'=>null,'master_id'=>null];
        if($keyword)
        {
            $user_id = UserModel::getUserIdByUserName($keyword);


            if($search_type == 'register')
            {
                $option['user_id']=$user_id;

            }else if($search_type == 'invite')
            {
                $option['invite_user_id']=$user_id;
            }else if($search_type == 'master')
            {
                $option['master_id']=$user_id;
            }
        }

        $query = InviteRecord::getRecord($option);
        
        $this->assign([
            'list'=>$query->paginate(),
            'keyword'=>$keyword,
            'search_type'=>$search_type,
            
        ]);

        return $this->fetch('index');
        
        
    }
}